package swardToOffer.struct_3_linkedlist;

/**
 * @Author ChanZany
 * @Date 2021/5/21 15:16
 * @Version 1.0
 */
public class LinkedListUtils {
    public static ListNode buildLinkedList(int[] nums) {
        ListNode p = new ListNode();
        ListNode head = p;
        for (int i = 0; i < nums.length; i++) {
            p.next = new ListNode(nums[i]);
            p = p.next;
        }
        return head.next;
    }

    public static void printLinkedList(ListNode head){
        while (head != null) {
            System.out.println(head.val);
            head = head.next;
        }
    }
}
